package com.freesky.biz.icbc.controller;

import com.freesky.biz.icbc.domain.TFinanceAccount;
import com.freesky.biz.icbc.domain.TFinanceReferrer;
import com.freesky.biz.icbc.domain.TFinanceReferrerCoupon;
import com.freesky.biz.icbc.domain.TSpecialRecord;
import com.freesky.biz.icbc.service.IFinanceReferrerService;
import com.freesky.biz.icbc.service.ISpecialRecordService;
import com.freesky.common.annotation.Log;
import com.freesky.common.core.controller.BaseController;
import com.freesky.common.core.domain.AjaxResult;
import com.freesky.common.core.page.TableDataInfo;
import com.freesky.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 工行推荐礼
 */
@RestController
@RequestMapping("/icbc/finance/referrer")
public class FinanceReferrerController extends BaseController {

    @Autowired
    private IFinanceReferrerService financeReferrerService;


    @PreAuthorize("@ss.hasPermi('icbc:finance:list')")
    @GetMapping("/list")
    public TableDataInfo list(TFinanceReferrer financeReferrer) {
        startPage();
        List<TFinanceReferrer> list = financeReferrerService.findList(financeReferrer);
        return getDataTable(list);
    }

    @Log(title = "工行推荐礼", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('icbc:finance:export')")
    @GetMapping("/export")
    public AjaxResult export(TFinanceReferrer financeReferrer,
                             HttpServletResponse response) {
        return financeReferrerService.exportFile(financeReferrer);
    }

    @PreAuthorize("@ss.hasPermi('icbc:finance:list')")
    @GetMapping("/listCoupon")
    public TableDataInfo listCoupon(TFinanceReferrerCoupon referrerCoupon) {
        startPage();
        List<TFinanceReferrerCoupon> list = financeReferrerService.findReferrerCouponList(referrerCoupon);
        return getDataTable(list);
    }

    @Log(title = "工行推荐礼", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('icbc:finance:export')")
    @GetMapping("/exportCoupon")
    public AjaxResult exportCoupon(TFinanceReferrerCoupon referrerCoupon,
                             HttpServletResponse response) {
        return financeReferrerService.exportCouponFile(referrerCoupon);
    }

    @PreAuthorize("@ss.hasPermi('icbc:finance:list')")
    @GetMapping("/listAccount")
    public TableDataInfo listAccount(TFinanceAccount financeAccount) {
        startPage();
        List<TFinanceAccount> list = financeReferrerService.findAccountList(financeAccount);
        return getDataTable(list);
    }

    @Log(title = "工行推荐礼", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('icbc:finance:export')")
    @GetMapping("/exportAccount")
    public AjaxResult exportAccount(TFinanceAccount financeAccount,
                             HttpServletResponse response) {
        return financeReferrerService.exportAccountFile(financeAccount);
    }

}
